package com.letsiot.applications.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.letsiot.applications.entity.SysRolePermission;
import com.letsiot.applications.repository.SysRolePermissionMapper;
import com.letsiot.applications.service.SysRolePermissionService;
import com.letsiot.common.data.IdUtil;

@Service
public class SysRolePermissionServiceImpl implements SysRolePermissionService {

    @Autowired
    private SysRolePermissionMapper sysRolePermissionMapper;

    @Override
    public int save(SysRolePermission entity) {
        if (entity.getId() == null) {
            entity.setId(IdUtil.getId());
        }
        return sysRolePermissionMapper.insertSelective(entity);
    }

    @Override
    public int delete(Long id) {
        return sysRolePermissionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(SysRolePermission entity) {
        return sysRolePermissionMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public SysRolePermission findById(Long id) {
        return sysRolePermissionMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysRolePermission> getAll() {
        return sysRolePermissionMapper.getAll();
    }

    @Override
    public List<SysRolePermission> getByRoleId(Long roleId) {
        return sysRolePermissionMapper.getByRoleId(roleId);
    }
}
